Illustration of CRS effect

Leaflet is able to handle several CRS (coordinate reference systems). It means that depending on the data you have, you may need to use the one or the other.

Don't worry ; in practice, almost everyone on the web uses EPSG3857 (the default value for folium and Leaflet). But it may be interesting to know the possible values.


In [1]:
import json
import sys
sys.path.insert(0,'..')
import folium
print (folium.__file__)
print (folium.__version__)


../folium/__init__.py
0.2.0.dev

Let's create a GeoJSON map, and change it's CRS.


In [2]:
geo_json_data = json.load(open('us-states.json'))

EPSG3857 ; the standard

Provided that our tiles are computed with this projection, this map has the expected behavior.


In [3]:
m = folium.Map([43,-100], zoom_start=4, crs='EPSG3857')

folium.GeoJson(geo_json_data).add_to(m)

m


Out[3]:

EPSG4326

This projection is a common CRS among GIS enthusiasts according to Leaflet's documentation. And we see it's quite different.


In [4]:
m = folium.Map([43,-100], zoom_start=4, crs='EPSG4326')

folium.GeoJson(geo_json_data).add_to(m)

m


Out[4]:

EPSG3395

The elliptical projection is almost equal to EPSG3857 ; though different.


In [5]:
m = folium.Map([43,-100], zoom_start=4, crs='EPSG3395')

folium.GeoJson(geo_json_data).add_to(m)

m


Out[5]:

Simple

At last, Leaflet also give the possibility to use no projection at all. With this, you get flat charts.

It can be useful if you want to use folium to draw non-geographical data.


In [6]:
m = folium.Map([43,-100], zoom_start=4, crs='Simple')

folium.GeoJson(geo_json_data).add_to(m)

m


Out[6]:

That's all folks !

Hope it'll be useful to you. Don't hesitate to provide a feedback on what can be improved, which method do you prefer, etc.